package com.example.image;

import android.content.Context;
import android.widget.ImageView;


import com.example.image.impl.GlideImpl;

import java.io.File;


public class ImageLoader implements IImageLoader {

    private IImageLoader loader;

    public ImageLoader(ImageLoaderType type){
        switch (type){
            case Glide:
                loader=new GlideImpl();
                break;
            case Picasso:
                throw new IllegalStateException("Picasso方案暂时未实现");
            default:
                loader=new GlideImpl();
                break;
        }
    }

    @Override
    public void loadFromUrl(Context context, String url, ImageView target, ImageOptions options) {
        loader.loadFromUrl(context,url,target,options);
    }

    @Override
    public void loadFromFile(Context context, File file, ImageView target, ImageOptions options) {
        loader.loadFromFile(context,file,target,options);
    }

    @Override
    public void loadFromResource(Context context, int resourceId, ImageView target, ImageOptions options) {
        loader.loadFromResource(context,resourceId,target,options);
    }
}
